<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>VueJS 计算属性</title>
    <script src="js/vue.js"></script>
    <script>
        window.onload = function () {
            let vm = new Vue({
                el: '#app',
                data: {
                    msg: 'welcome to app',
                    num1:5
                },
                computed: {  //计算属性
                    msg2: function () {
                        return this.msg.split(' ').reverse().join(' ')
                    }
                },
                methods:{
                    change(){
                        this.msg = "Hello Wolrd!";
                        console.log(vm);
                    }
                }
            })
        }
    </script>
</head>

<body>
    <div id="app">
        <h1 v-text="msg"></h1>
        <h1 v-text="msg2"></h1>
        <button type="button" @click="change"> 改变值</button>
    </div>
</body>

</html>